<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数</title>
</head>
<body>

</body>
<script>
/*m到n的奇数和命名函数实现和匿名函数实现*/
    function num(m,n){
        let sum=0;
        for (let i = m; i <=n; i++) {
            (i%2==0)?sum+=0:sum+=i;
        }
        document.write(sum);
    }
    num(1,5)

    let f=function(m,n){
        let sum=0;
        for (let i = m; i <=n ; i++) {
            (i%2==0)?sum+=0:sum+=i;
        }
        alert(sum);
    }
    f(2,6);
</script>
</html>